/**
 * 
 */
package com.dalonedrow.rpg.base.systems;

import com.dalonedrow.engine.sprite.base.SimpleVector2;

/**
 * 
 * @author Donald
 *
 * @param <IO>
 */
public interface Inventory<IO> {
	/**
	 * Sets the current player whose inventory is being viewed.
	 * @param playerIO the player
	 */
	void setPlayerViewed(IO playerIO);
	/**
	 * Gets the current player whose inventory is being viewed.
	 * @return {@link IO}
	 */
	IO getPlayerViewed();
	/**
	 * Determines if an item can be put in the player's inventory.
	 * @param item the item
	 * @param playerIO the player
	 * @return true if the item has been added; false otherwise
	 * @throws Exception if an error occurs
	 */
	boolean canBePutInInventory(IO item, IO playerIO) throws Exception;
	/**
	 * Checks a player's inventory for one item to be replaced with a second in
	 * a player's inventory.
	 * @param item1 the first item
	 * @param item2 the second item
	 * @param playerIO the player
	 * @throws Exception if an error occurs
	 */
	void checkForInventoryReplaceMe(IO item1,
			IO item2, IO playerIO) throws Exception;
	/**
	 * Cleans the player's inventory.
	 * @param playerIO the player
	 */
	void cleanInventory(IO playerIO);
	/**
	 * Declares an item to be in the player's inventory, sending the appropriate
	 * event to the player and the item.
	 * @param item the item
	 * @param playerIO the player
	 * @throws Exception if an error occurs
	 */
	void declareInInventory(IO item, IO playerIO) throws Exception;
	boolean dragSuccessful();
	/**
	 * Gets the inventory item found at a specific position.
	 * @param x the x-coordinate
	 * @param y the y-coordinate
	 * @return {@link IO}
	 */
	IO getInventoryObject(float x, float y);
	/**
	 * Attempts to identify all items in the player's inventory, if the player
	 * is able to.
	 * @param playerIO the player
	 */
	void identifyAll(IO playerIO);
	/**
	 * Attempts to identify a specific items, if the player is able to.
	 * @param item the item
	 * @param playerIO the player
	 */
	void identifyItem(IO item, IO playerIO);
	/**
	 * Determines if an item is in the player's inventory.
	 * @param item the item
	 * @param playerIO the player
	 * @return true if the player has the item; false otherwise
	 */
	boolean isInPlayerInventory(IO item, IO playerIO);
	/**
	 * Puts an interactive object in front of the pc.
	 * @param item the item
	 * @param playerIO the player
	 * @param applyPhysics if true, physics is applied when dropping the item;
	 *        false otherwise
	 */
	void putInFrontOfPlayer(IO item, IO playerIO,
			boolean applyPhysics);
	void dropItem(IO ioSource, IO ioItem, boolean inSameSpot);
	/**
	 * Removes an item from a player's inventory.
	 * @param item the item
	 * @param playerIO the player
	 * @throws Exception if an error occurs
	 */
	void removeFromAllInventories(IO item, IO playerIO) throws Exception;
	/**
	 * Replaces one item with a second in a player's inventory.
	 * @param item1 the first item
	 * @param item2 the second item
	 * @param playerIO the player
	 * @throws Exception if an error occurs
	 */
	void replaceInAllInventories(IO item1,
			IO item2, IO playerIO) throws Exception;
	/**
	 * Sends a script event to an item in the player's inventory.
	 * @param itemName the item's name
	 * @param commandId the reference id of the script event to execute
	 * @param playerIO the player
	 * @throws Exception if an error occurs
	 */
	void sendInventoryObjectCommand(String itemName, int commandId, 
			IO playerIO) throws Exception;
	/**
	 * Takes an object from the player's inventory at screen position "xx,yy".
	 * @param pos the position
	 * @param playerIO the player
	 * @return true if the object was taken; false otherwise
	 */
	boolean takeFromInventory(SimpleVector2 pos, IO playerIO);
}
